#ifndef __IRS2975C_FLASH_H__
#define __IRS2975C_FLASH_H__
#include "sensor_helper.h"
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/module.h>
#include <media/v4l2-device.h>

#define RX_SLAVE_ADDR 0x7a

/*register addresses*/
#define PLL_SYSLUT_CFG0_ADDR 0xA02F
#define PLL_SYSLUT_CFG1_ADDR 0xA030
#define PLL_SYSLUT_CFG2_ADDR 0xA031
#define PLL_SYSLUT_CFG3_ADDR 0xA032
#define PLL_SYSLUT_CFG4_ADDR 0xA033
#define PLL_SYSLUT_CFG5_ADDR 0xA034
#define PLL_SYSLUT_CFG6_ADDR 0xA035
#define RESTARTV_EN_ADDR 0x8663
#define FUNCNUM_ADDR 0x93D3
#define CTRL_ADDR 0x8601
#define CMC_ADDR 0xA085
#define SPICFG_ADDR 0xA095
#define SPIWRADDR_ADDR 0xA096
#define SPIRADDR_ADDR 0xA097
#define SPILEN_ADDR 0xA098
#define SPITRIG_ADDR 0xA099
#define SPISTATUS_ADDR 0xA09A

/*register settings for setting up SPI*/
//#define SPICFG_VAL 0xD003
#define SPICFG_VAL 0x5003
#define SPIWRADDR_VAL 0x0000
#define SPIRADDR_VAL 0x0100

#define DEVICE_INFO_HEAD_ADDR 0X200
#define CALIB_FILE_HEAD_ADDR 0X01000
#define SN_HEAD_ADDR 0X000000

#define CALIB_INFO_MAX_LEN (192 * 1024 - 256)

typedef struct rx_spi_flash {
	bool spi_setup_done;
	unsigned int f_ref;
	struct v4l2_subdev *sd;
} RX_SPI_FH;

extern int read_sn(struct v4l2_subdev *sd, char *sn);
extern int read_calib_info(struct v4l2_subdev *sd, char *calib_info, int *len,
			   int *crc32_value);
extern int write_sn(struct v4l2_subdev *sd, char *sn, int len);
extern int read_device_info(struct v4l2_subdev *sd, uint8_t* info);

#endif
